// pages/order/detail.js
var common = require("../../utils/util.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: '',
    status: 1,  //todo 订单状态
    info: {},
    isRunner: false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let userInfo = wx.getStorageInfoSync('userInfo');
    this.setData({
      id: options.id,
      isRunner: userInfo.account_type && userInfo.account_type==2 && options.ordertype && options.ordertype=='accept'
    })
    this.getDetail();
  },

  getDetail() {
    let that = this;
    wx.showLoading({
      title: "加载中",
    });
    common.getData_user(common.config.OrderDetail, {
      order_no: that.data.id,
    }, "post", function (res) {
      wx.hideLoading();
      that.setData({
        info: res
      });
    });
  },
  // 核销
  onCheck() {
    wx.showLoading({
      title: "加载中",
    });
    common.getData_user(common.config.ConfirmOrder, {
      order_no: this.data.id,
    }, "post", function (res) {
      wx.hideLoading();
      wx.navigateBack()
    });
  },
  // 接单
  getOrder() {
    wx.showLoading({
      title: "加载中",
    });
    common.getData_user(common.config.RushOrder, {
      order_no: this.data.id,
    }, "post", function (res) {
      wx.hideLoading();
      wx.navigateBack()
    });
  }
})